(function(){
    let form = layui.form
    form.verify({
        nickname:[
            /^[\S]{1,10}$/,
            `昵称长度为1-10个字符`
        ]
    })
    let layer = layui.layer
    initUser_info()
    function initUser_info(){
        axios({
            method:'GET',
            url:'/my/userinfo',

        }).then(res=>{
            // console.log(res);
            if(res.data.status!==0){
                layer.msg(res.data.message)
            }
            // layer.msg(res.data.message)
            form.val('formUserInfo',res.data.data)

        })
    }



    // $('form')on('reset',function(){})
    $('#restbut').click(function(e){
        e.preventDefault()
        initUser_info()
    })

    $('form').on('submit',function(e){
        e.preventDefault()
        axios({
            method:'POST',
            url:'/my/userinfo',
            data:$(this).serialize(),
        }).then(res=>{
            if(res.data.status!==0){
                return layui.layer.msg(res.data.message)
            }
            layui.layer.msg(res.data.message)
            console.log(res);
            window.parent.getUserInfo()
        })
    })


})();